package com.pth.dao.impl;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.pth.dao.AdminDAO;
import com.pth.model.Admin;

public class AdminDAOImpl implements AdminDAO {

	private HibernateTemplate hibernateTemplate;
	
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}

	public void save(Admin admin) {

		hibernateTemplate.save(admin);
	}

	public void delete(Admin admin) {

		hibernateTemplate.delete(admin);
	}

	public boolean login(Admin admin) {

		String hql="from Admin where adminnumber='"+admin.getAdminnumber()+"' and adminpassword='"+admin.getAdminpassword()+"'";
		
		int size=hibernateTemplate.find(hql).size();
		
		boolean flag=false;
		
		if(size>0){
			
			flag=true;
			
		}
		return flag;
	}

}
